#include <bits/stdc++.h>

template <typename It, class Compare =
          std::less<typename std::iterator_traits<It>::value_type> >
It my_partition(It begin, It end,
               const typename std::iterator_traits<It>::value_type &x,
               Compare comp = Compare()) {
    typedef typename std::iterator_traits<It>::value_type T;
    if (begin == end)
        return begin;
    It left = begin, right = std::prev(end);
    while (left != right) {
        while (left != right && comp(*left, x))
            ++left;
        while (left != right && !comp(*right, x))
            --right;
        if (left != right) {
            std::iter_swap(left, right);
            ++left;
        }
        
    }
    if (comp(*left, x))
        return std::next(left);
    else
        return left;    
}

template <typename It, class Compare =
          std::less<typename std::iterator_traits<It>::value_type> >
void my_sort(It begin, It end, Compare comp = Compare()) {
    typedef typename std::iterator_traits<It>::value_type T;
    static std::minstd_rand eng;
    auto n = std::distance(begin, end);
    if (n <= 1)
        return;
    std::uniform_int_distribution<std::size_t> distr(0, n - 1);
    auto x = *std::next(begin, distr(eng));
    auto mid = my_partition(begin, end, x, comp);
    //assert(std::all_of(begin, mid, [&](const T &y) { return  comp(y, x); }));
    //assert(std::all_of(mid,   end, [&](const T &y) { return !comp(y, x); }));
    if (mid == begin && *begin == x) {
        my_sort(begin+1, end, comp);
        return;
    }
    my_sort(begin, mid, comp);
    my_sort(mid, end, comp);
}

template <typename T>
std::vector<T> read_array(std::istream &in=std::cin) {
    int n;
    in >> n;
    std::vector<T> result(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> result[i];
    }
    return result;
}

int main() {
    auto a = read_array<int>();
    int x;
    std::cin >> x;
    auto mid = my_partition(a.begin(), a.end(), x);
    std::cout << std::distance(a.begin(), mid) << '\n'
              << std::distance(mid, a.end()) << '\n';
}
